<template>
<pre lang="json">{{ state }}</pre>
<div>flag: {{ flag }}</div>

<button @click="changeState">更新用户信息</button>
</template>
<script setup lang="ts">
import { useStorage } from '@vueuse/core';


const state = useStorage('userInfo', { hello: 'hi', greeting: 'hello' })
// 用sessionStorage存储
const flag = useStorage('flag', true, sessionStorage)

const changeState = () => {
  state.value.time = Date.now()
}
</script>